package com.wisemoresystem.seal.service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.ne.framework.data.page.Page;
import org.ne.framework.data.util.ChkTools;
import org.springframework.stereotype.Service;

import com.wisemoresystem.seal.base.service.BaseService;
import com.wisemoresystem.seal.util.DateTools;

/**
 * 设备日志管理
 * @author 张永宣
 *
 */
@Service
public class MacLogService extends BaseService{
	public List<Map<String,Object>> selectMacLogList(String srh_name,String srh_start,
			String srh_end,String bank_id,final Page page){
		
		String sql = "select "+
		" t.* ,tbbb.name bbbname ,tb.name bname,tbb.name vbname,tu.uname,tuu.uname vuname,tm.code "+
		"	from t_mac_move_log t "+
		" left join t_bank tb on t.bank_id = tb._id "+
		" left join t_bank tbb on t.bank_id_dest = tbb._id  "+
		" left join t_user tu on t.user_id = tu._id "+
		" left join t_user tuu on t.verify_user_id = tuu._id "+
		" left join t_bank tbbb on t.verify_bank_id = tbbb._id "+
		" left join t_mac tm on t.mac_id = tm._id "+
		" WHERE t.bank_id=? and "+
		" t.type like ? and t.status=0 and t.created>=? and t.created<=? order by t.created desc";
		
		List<String> params = new ArrayList<String>();
		params.add(bank_id);
		if (ChkTools.isNull(srh_name)) {
			sql = sql.replace("t.type like ? and ", "");
		} else {
			params.add("%" + srh_name + "%");
		}
		if (ChkTools.isNull(srh_start)) {
			sql = sql.replace("and t.created>=? and t.created<=?", "");
		} else {
			params.add(srh_start);
			params.add(DateTools.addOneDay(srh_end));
		}
		
		List<Map<String,Object>> list = jc.queryForList(sql, params.toArray(),page);
		return list;
		
	}
}
